package com.qidian.common.beanCache;

import java.util.concurrent.ConcurrentHashMap;

import com.qidian.common.beans.RechargeCardBean;

public final class RechargeCardBeanCache
{    
	private static RechargeCardBeanCache RechargeCardBeanCache = new RechargeCardBeanCache() ;
    
	/*	<充值卡号,充值卡>	*/
	public ConcurrentHashMap<String,RechargeCardBean> buffer  ;
	
    private RechargeCardBeanCache()
    {
    	buffer = new ConcurrentHashMap<String,RechargeCardBean>(1024) ;
    }
    
    public static RechargeCardBeanCache getInstance()
    {
    	return RechargeCardBeanCache ;
    }
    
    public void add(RechargeCardBean rechargeCardBean)
    {
    	if (rechargeCardBean == null)
    		return ;
    	buffer.put(rechargeCardBean.getRechargeCode(), rechargeCardBean) ;
//    	System.out.println("Current recharge card count:"+buffer.size());
    }
    public RechargeCardBean get(String rechargeCode)
    {
    	return buffer.get(rechargeCode.toLowerCase()) ;
    }
	
    public boolean isValid(String rechargeCode)
    {
    	if (rechargeCode == null)
    		return false ;
    	return buffer.containsKey(rechargeCode.toLowerCase()) ;
    }
}
